package com.joinval.modules.joinval.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;
import java.util.stream.Stream;

/**
 * @Author zhizuntop
 * @create 2023/9/5 11:25
 */
@Getter
@AllArgsConstructor
public enum RoleCode {

    ENTERPRISE("enterprise", "企业"),
    /**
     * 街镇专员
     */
    TOWN("town", "街镇专员"),
    /**
     * 区专员
     */
    DISTRICT("district", "区专员"),
    /**
     * 检查员
     */
    INSPECTOR("inspector", "检查员"),

    /**
     * 市商联会
     */
    CITY_COMMERCE("city-commerce", "市商联会"),
    /**
     * 市级主管部门
     */
    CITY_COMPETENT_DEPARTMENT("city-competent-department", "市级主管部门"),
    /**
     * 餐饮行业协会
     */
    FOODINDUSTRY("foodIndustry", "餐饮行业协会"),

    PLATFORM_OPERATION("platform_operation", "平台运营角色"),


    ADMIN("admin", "管理员"),
    ;

    /** 编码 */
    private final String code;

    /** 描述 */
    private final String description;

    /**
     *
     * */
    public static RoleCode of(String code) {

        Objects.requireNonNull(code);

        return Stream.of(values())
                .filter(bean -> bean.code.equals(code))
                .findAny()
                .orElseThrow(
                        () -> new IllegalArgumentException(code + " not exists")
                );
    }
}
